﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/**
* 球控制器
* @author lichenyi
* 2018-07-16 13:30:11
*/
public class Player : MonoBehaviour
{
    public static Player initialize; 
    public float speed; //The speed of ball rolling
    public GameObject camera;//camera
    private Rigidbody rb;

    private void Awake()
    {
        if (initialize == null)
            initialize = this;
        else if(initialize != null)
            Destroy(initialize);
    }
    
    public void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

    void Update()
    {
        float moveHorizontal = Input.GetAxis("Horizontal"); //horizontal distance
        float moveVertical = Input.GetAxis("Vertical"); //vertical distance

        Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);//Control the player to move forward and backward.
        rb.AddForce(movement * speed);
        //TODO
        //rb.volicity
    }

}